package com.xlh.Utils;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

/**
 * Created by fang on 2018-01-16.
 */

public class DBManager {

    private String tableName;

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public SQLiteDatabase getDb() {
        if(db==null || !db.isOpen()){
            db = dbHelper.getWritableDatabase();
        }
        return db;
    }
    private SQLiteDatabase db;
    private DataBaseHelper dbHelper;
    public DBManager(Context context) {
        dbHelper = new DataBaseHelper(context,"",null,1);
        //因为getWritableDatabase内部调用了mContext.openOrCreateDatabase(mName, 0, mFactory);

    }

    public void claseDataBase() {
        db.close();
    }


}
